<template>
	<view>
		
		<view class="item">
			<view class="tit">
				input type=text 文本输入键盘
			</view>
			<view>
				长度：{{form.data1.length}}
			</view>
			<input type="text" v-model="form.data1"  @input="onInput($event,'data1')" class="input" placeholder="请输入">
		</view>
		
		<view class="item">
			<view class="tit">
				input type=number 数字输入键盘
			</view>
			<view>
				长度：{{form.data2.length}}
			</view>
			<input type="number" v-model="form.data2"  @input="onInput($event,'data2')" class="input" placeholder="请输入">
		</view>
		
		<view class="item">
			<view class="tit">
				input type=digit 	带小数点数字输入键盘
			</view>
			<view>
				长度：{{form.data3.length}}
			</view>
			<input type="digit" v-model="form.data3"  @input="onInput($event,'data3')" class="input" placeholder="请输入">
		</view>
		<view class="item">
			<view class="tit">
				textarea type=textarea
			</view>
			<view>
				长度：{{form.data4.length}}
			</view>
			<textarea  class="input2" v-model="form.data4"  @input="onInput($event,'data4')" placeholder="请输入"></textarea>
		</view>
		
	</view>
</template>


<script>
	import {
		mapState,
		mapActions,
		mapMutations,
		mapGetters
	} from 'vuex';
	import {
		mixinsBase
	} from '@/common/js/mixins';
	import throttle from '@/common/js/throttle.js';
	let that;
	export default {
		mixins: [mixinsBase],
		components: {
		},
		data() {
			return {
				form:{
					data1:'',
					data2:'',
					data3:'',
					data4:'',
				},
			};
		},
		onLoad(o) {
		},
		onReady() {
		},
		onShow() {
			// #ifdef H5
			this.$common.h5SetTitle('');
			// #endif
		},
		onUnload() {
			that = null
		},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {
			// this.getInit(data=>{
			//      uni.stopPullDownRefresh();
			//      common.showTip('刷新成功');
			// });
		},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},

		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {
			//       return {
			// 	// path,
			// 	imageUrl:config.shareImg,
			// 	// title
			// }
		},
		methods: {
			onInput(e, name){
				console.log('handleInput ee', e)
				let value = this.$u.trim(e.detail.value, 'all')
				this.$set(this.form,name,e.detail.value)
			},
			submitInput(){
				if(this.value.length != 6){
					this.innerAudioContext.play();
					this.$common.showTip('编码数错误');
					return
				}
				if(this.isHas(this.value) != -1 ){
					this.innerAudioContext.play();
					this.$common.showTip('编码重复');
					return
				} 
				if(this.form.type == 7 && this.isHasTb(this.value) == -1 ){
					this.innerAudioContext.play();
					this.$common.showTip('当前站点不存在编码');
					return
				}
				if(this.form.type == 2 && this.isHasCz(this.value) == -1 ){
					this.innerAudioContext.play();
					this.$common.showTip('当前站点不存在编码');
					return
				}
				
				this.form.bottle_code[this.tagIndex] = this.value
				this.value = '';
				this.showEdit = false;
			},
			handleTag(e, index){
				this.value = e;
				this.tagIndex= index;
				this.showEdit = true;
			},
			...mapActions([]),
		},
	};
</script>

<style lang="scss">
	.item{
		padding: 30rpx;
		border-bottom: 1px solid #ddd;
	}
	.tit{
		font-size: 14px;
	}
	
	.input{
		background: #eee;
		width: 100%;
		padding: 0 10px;
		height: 40px;
		line-height: 40px;
	}
	.input2{
		background: #eee;
		width: 100%;
		padding: 5px 10px;
	}
</style>